package com.yayohos.locationmanager.providers.permissionprovider;

import ohos.aafwk.ability.Ability;
import ohos.bundle.IBundleManager;

/**
 * PermissionCompatSource 权限业务实现
 *
 * @date 2021/5/26
 */
class PermissionCompatSource {
    boolean shouldShowRequestPermissionRationale(Ability ability, String permission) {
        if (ability.verifySelfPermission(permission) != IBundleManager.PERMISSION_GRANTED) {
            return ability.canRequestPermission(permission);
        } else {
            // 权限已被授予
            return false;
        }
    }

    void requestPermissions(Ability ability, String[] requiredPermissions, int requestCode) {
        ability.requestPermissionsFromUser(requiredPermissions, requestCode);
    }

}
